package com.eleven.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.eleven.dao.LetterMapper;
import com.eleven.pojo.Letter;
import com.eleven.pojo.LetterExample;
import com.eleven.service.LetterService;
@Service
public class LetterServiceImpl implements LetterService{
	@Autowired
	LetterMapper letterMapper;
	
	public LetterMapper getLetterMapper() {
		return letterMapper;
	}


	public void setLetterMapper(LetterMapper letterMapper) {
		this.letterMapper = letterMapper;
	}
	
	/**
	 * 查看自己的私信(包括有收到的私信和发出的私信)
	 */
	public List<Letter> getMyLetter(Integer id) {
		LetterExample letterExample =new LetterExample();
		letterExample.createCriteria().andLeIdEqualTo(id);
		return letterMapper.selectByExample(letterExample);
	}
	
	/**
	 * 回复私信(发出私信)
	 */
	public int insertLetter(Letter letter) {
		return 0;
	}
	
	/**
	 * 删除私信
	 */
	public int deleteLetter(Integer id) {
		LetterExample letterExample =new LetterExample();
		letterExample.createCriteria().andLeIdEqualTo(id);
		return letterMapper.deleteByExample(letterExample);
	}
	
	/**
	 * 查看全部私信
	 */
	public List<Letter> getAllLetter() {
		return letterMapper.selectByExample(null);
	}

	/**
	 * 查看全部私信降序
	 */
	public List<Letter> getAllLetterTime() {
		// TODO Auto-generated method stub
		return letterMapper.selectByExampleTime();
	}


}
